package com.ruoyi.web.controller.test2;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.test4.domain.Equipment;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.test2.domain.Materialtable;
import com.ruoyi.test2.service.IMaterialtableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物资管理Controller
 * 
 * @author 22082112
 * @date 2025-07-08
 */
@RestController
@RequestMapping("/materialtable/materialtable")
public class MaterialtableController extends BaseController
{
    @Autowired
    private IMaterialtableService materialtableService;

    @GetMapping("/listAll")
    public AjaxResult listAll() {
        List<Materialtable> list = materialtableService.selectMaterialtableList(new Materialtable());
        return success(list);
    }
    /**
     * 查询物资管理列表
     */
    @PreAuthorize("@ss.hasPermi('materialtable:materialtable:list')")
    @GetMapping("/list")
    public TableDataInfo list(Materialtable materialtable)
    {
        startPage();
        List<Materialtable> list = materialtableService.selectMaterialtableList(materialtable);
        return getDataTable(list);
    }

    /**
     * 导出物资管理列表
     */
    @PreAuthorize("@ss.hasPermi('materialtable:materialtable:export')")
    @Log(title = "物资管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Materialtable materialtable)
    {
        List<Materialtable> list = materialtableService.selectMaterialtableList(materialtable);
        ExcelUtil<Materialtable> util = new ExcelUtil<Materialtable>(Materialtable.class);
        util.exportExcel(response, list, "物资管理数据");
    }

    /**
     * 获取物资管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('materialtable:materialtable:query')")
    @GetMapping(value = "/{supplyid}")
    public AjaxResult getInfo(@PathVariable("supplyid") Long supplyid)
    {
        return success(materialtableService.selectMaterialtableBySupplyid(supplyid));
    }

    /**
     * 新增物资管理
     */
    @PreAuthorize("@ss.hasPermi('materialtable:materialtable:add')")
    @Log(title = "物资管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Materialtable materialtable)
    {
        return toAjax(materialtableService.insertMaterialtable(materialtable));
    }

    /**
     * 修改物资管理
     */
    @PreAuthorize("@ss.hasPermi('materialtable:materialtable:edit')")
    @Log(title = "物资管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Materialtable materialtable)
    {
        return toAjax(materialtableService.updateMaterialtable(materialtable));
    }




    /**
     * 删除物资管理
     */
    @PreAuthorize("@ss.hasPermi('materialtable:materialtable:remove')")
    @Log(title = "物资管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{supplyids}")
    public AjaxResult remove(@PathVariable Long[] supplyids)
    {
        return toAjax(materialtableService.deleteMaterialtableBySupplyids(supplyids));
    }

}
